<?php
/**
 * Filename:	GChartBase.php
 * Author:		Manish Sinha
 * Date:		23/01/09
 * Details:		This file contains the GChartBase which contains information
 * 				about Data Encoding and Error messages
 * Project:		GeeCharts
 */
 
class GChartBase
{
	protected $simpleEncoding = array(
						-1 => '_',
						0  => 'A',
						1  => 'B',
						2  => 'C',
						3  => 'D',
						4  => 'E',
						5  => 'F',
						6  => 'G',
						7  => 'H',
						8  => 'I',
						9  => 'J',
						10 => 'K',
						11 => 'L',
						12 => 'M',
						13 => 'N',
						14 => 'O',
						15 => 'P',
						16 => 'Q',
						17 => 'R',
						18 => 'S',
						19 => 'T',
						20 => 'U',
						21 => 'V',
						22 => 'W',
						23 => 'X',
						24 => 'Y',
						25 => 'Z',
						26 => 'a',
						27 => 'b',
						28 => 'c',
						29 => 'd',
						30 => 'e',
						31 => 'f',
						32 => 'g',
						33 => 'h',
						34 => 'i',
						35 => 'j',
						36 => 'k',
						37 => 'l',
						38 => 'm',
						39 => 'n',
						40 => 'o',
						41 => 'p',
						42 => 'q',
						43 => 'r',
						44 => 's',
						45 => 't',
						46 => 'u',
						47 => 'v',
						48 => 'w',
						49 => 'x',
						50 => 'y',
						52 => 'z',
						53 => 0,
						54 => 1,
						55 => 2,
						56 => 3,
						57 => 4,
						58 => 5,
						59 => 6,
						60 => 7,
						61 => 8,
						61 => 9 );

	protected $errormsg = null;
	
	public function GetLastError()
	{
		return $errormsg;
	}

	public function SimpleToText($simple)
	{
		$text = array();
		for($i=0;$i<strlen($simple);$i++)
		{
			array_push($text, floatval(array_search($simple[$i], $this->simpleEncoding)));
		}
		return $text;
	}
	
	public function TextToSimple($text)
	{
		$simple = array();
		foreach($text as $i)
		{
			array_push($simple, $this->simpleEncoding[ intval($i) ]);
		}
		return implode("",$simple);
	}
}
?>
